<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>命令介绍 | CatchAdmin 官网</title>
    <meta name="description" content="">
    <meta name="generator" content="VuePress 1.8.2">
    <style>a[title="站长统计"]{display:none}</style>
    <script data-ad-client="ca-pub-1505209242532150" async="true" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script src="https://v1.cnzz.com/z_stat.php?id=1279921342&amp;web_id=1279921342"></script>
    <meta name="description" content="基于 Thinkphp & Vue 开发的后台管理框架">
    <meta name="keywords" content="catchadmin, 后台管理, 前后端分离, thinkphp后台管理框架, thinkphp前后端分离框架,php, elementui">
    <link rel="preload" href="/assets/css/0.styles.6834c255.css" as="style"><link rel="preload" href="/assets/js/app.d0396f44.js" as="script"><link rel="preload" href="/assets/js/2.1cef47df.js" as="script"><link rel="preload" href="/assets/js/8.35122549.js" as="script"><link rel="prefetch" href="/assets/js/10.483f2013.js"><link rel="prefetch" href="/assets/js/11.981d4461.js"><link rel="prefetch" href="/assets/js/12.95d2c383.js"><link rel="prefetch" href="/assets/js/13.061c2fe0.js"><link rel="prefetch" href="/assets/js/14.ec2753db.js"><link rel="prefetch" href="/assets/js/15.8ba1c321.js"><link rel="prefetch" href="/assets/js/16.f7f0d34c.js"><link rel="prefetch" href="/assets/js/17.aac0bf62.js"><link rel="prefetch" href="/assets/js/18.2e2fe306.js"><link rel="prefetch" href="/assets/js/19.aee304b3.js"><link rel="prefetch" href="/assets/js/20.86a73bc1.js"><link rel="prefetch" href="/assets/js/21.8992c972.js"><link rel="prefetch" href="/assets/js/22.0a78500a.js"><link rel="prefetch" href="/assets/js/23.06342909.js"><link rel="prefetch" href="/assets/js/24.06fd96a3.js"><link rel="prefetch" href="/assets/js/25.00664d4e.js"><link rel="prefetch" href="/assets/js/26.c3d4b548.js"><link rel="prefetch" href="/assets/js/27.3c6927ad.js"><link rel="prefetch" href="/assets/js/28.74498c0b.js"><link rel="prefetch" href="/assets/js/29.aae1a826.js"><link rel="prefetch" href="/assets/js/3.4d2bdca7.js"><link rel="prefetch" href="/assets/js/30.c7732a2c.js"><link rel="prefetch" href="/assets/js/31.20403043.js"><link rel="prefetch" href="/assets/js/32.7b8e9cfe.js"><link rel="prefetch" href="/assets/js/33.8610da11.js"><link rel="prefetch" href="/assets/js/4.d7b1015b.js"><link rel="prefetch" href="/assets/js/5.ff87de2e.js"><link rel="prefetch" href="/assets/js/6.0e91e688.js"><link rel="prefetch" href="/assets/js/7.ba30e213.js"><link rel="prefetch" href="/assets/js/9.081b18e5.js">
    <link rel="stylesheet" href="/assets/css/0.styles.6834c255.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="ant-row"><div class="sidebar-button"><i aria-label="icon: bars" class="anticon anticon-bars"><svg viewBox="0 0 1024 1024" focusable="false" data-icon="bars" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M912 192H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM104 228a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg></i> <span></span></div> <div class="ant-col ant-col-xs-24 ant-col-sm-24 ant-col-md-6 ant-col-lg-5 ant-col-xl-5 ant-col-xxl-4"><a href="/" class="router-link-active no-logo home-link"><!----> <span class="site-name">CatchAdmin 官网</span></a> <div class="search-box mobile-search"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div></div> <div class="ant-col ant-col-xs-0 ant-col-sm-0 ant-col-md-18 ant-col-lg-19 ant-col-xl-19 ant-col-xxl-20"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><ul role="menu" id="nav" class="ant-menu ant-menu-horizontal ant-menu-root ant-menu-light"><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/" class="router-link-active">
          🏠首页
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item ant-menu-item-selected"><a href="/docs/" class="router-link-active">
          📖文档
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/laravel/">
          📖Laravel
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/faq/">
          🤔FAQ
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/donate/">
          🎉赞助名单
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>
          🚀仓库地址
        </span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="visibility:hidden;position:absolute;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li></ul> <!----></nav></div></div> <!----></header> <aside class="sidebar"><div><div class="ads"><div id="ads_1"><img src="https://cover.kancloud.cn/akasishikelu/thinkphp6!middle"> <span title="基于 catchadmin 的 Thinkphp 6.0 企业级后台管理开发&amp;源码分析">基于 catchadmin 的 Thinkphp 6.0 企业级后台管理开发&amp;源码分析</span></div></div> <div role="separator" id="reset-margin" class="ant-divider ant-divider-horizontal ant-divider-dashed"></div></div> <ul class="sidebar-links"><li><a href="/docs/" aria-current="page" title="项目介绍" class="sidebar-link">项目介绍</a></li><li><a href="/docs/install.html" title="项目安装" class="sidebar-link">项目安装</a></li><li><a href="/docs/project-introduce.html" title="目录结构" class="sidebar-link">目录结构</a></li><li><a href="/docs/console.html" aria-current="page" title="命令介绍" class="active sidebar-link">命令介绍</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/console.html#安装框架" title="安装框架" class="sidebar-link">安装框架</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#备份数据" title="备份数据" class="sidebar-link">备份数据</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#创建模块-废弃-请使用后台的代码生成" title="创建模块（废弃）请使用后台的代码生成" class="sidebar-link">创建模块（废弃）请使用后台的代码生成</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#创建-migration" title="创建 Migration" class="sidebar-link">创建 Migration</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#创建表" title="创建表" class="sidebar-link">创建表</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#创建模型" title="创建模型" class="sidebar-link">创建模型</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#模块禁用" title="模块禁用" class="sidebar-link">模块禁用</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#模块启用" title="模块启用" class="sidebar-link">模块启用</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#打包模块" title="打包模块" class="sidebar-link">打包模块</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#模块服务发现" title="模块服务发现" class="sidebar-link">模块服务发现</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#导出菜单" title="导出菜单" class="sidebar-link">导出菜单</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#执行-migrate" title="执行 migrate" class="sidebar-link">执行 migrate</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#填充数据" title="填充数据" class="sidebar-link">填充数据</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#缓存敏感词" title="缓存敏感词" class="sidebar-link">缓存敏感词</a></li><li class="sidebar-sub-header"><a href="/docs/console.html#重置超管密码" title="重置超管密码" class="sidebar-link">重置超管密码</a></li></ul></li><li><a href="/docs/request.html" title="请求介绍" class="sidebar-link">请求介绍</a></li><li><a href="/docs/model.html" title="模型介绍" class="sidebar-link">模型介绍</a></li><li><a href="/docs/dataScope.html" title="权限介绍" class="sidebar-link">权限介绍</a></li><li><a href="/docs/extend.html" title="项目扩展" class="sidebar-link">项目扩展</a></li><li><a href="/docs/http.html" title="Http客户端" class="sidebar-link">Http客户端</a></li><li><a href="/docs/excel.html" title="Excel" class="sidebar-link">Excel</a></li><li><a href="/docs/sensitiveWord.html" title="敏感词" class="sidebar-link">敏感词</a></li><li><a href="/docs/crontab.html" title="定时任务新版" class="sidebar-link">定时任务新版</a></li><li><a href="/docs/catch-table.html" title="表格组件" class="sidebar-link">表格组件</a></li><li><a href="/docs/front.html" title="前端开发" class="sidebar-link">前端开发</a></li></ul></aside> <main class="page"> <div class="theme-antdocs-content content__default"><h1 id="命令介绍"><a href="#命令介绍" class="header-anchor">#</a> 命令介绍</h1> <p>命令行请务必看一下，对于你开发会有很大的帮助，提升你的开发效率。<code>CatchAdmin</code> 提供了很多有用的命令，在你的开发使用熟练的话，将会大大增加你的开发效率。</p> <h2 id="安装框架"><a href="#安装框架" class="header-anchor">#</a> 安装框架</h2> <div class="language- extra-class"><pre class="language-text"><code>php think catch:install
</code></pre></div><h4 id="参数列表"><a href="#参数列表" class="header-anchor">#</a> 参数列表</h4> <ul><li>可选参数 <code>-r</code>，重置数据库</li></ul> <div class="custom-block warning"><p class="custom-block-title">WARNING</p> <p>使用该选项参数, 通过 migration 的生成的表将会被回滚删除，然后重新添加初始化数据.</p></div> <h2 id="备份数据"><a href="#备份数据" class="header-anchor">#</a> 备份数据</h2> <div class="language- extra-class"><pre class="language-text"><code>php think backup:data
</code></pre></div><h4 id="参数列表-2"><a href="#参数列表-2" class="header-anchor">#</a> 参数列表</h4> <ul><li>必选参数 <code>tables</code>, 多个表需要使用 , 分隔开</li></ul> <h4 id="事例"><a href="#事例" class="header-anchor">#</a> 事例</h4> <div class="language- extra-class"><pre class="language-text"><code>php think backup:data users,roles
</code></pre></div><h2 id="创建模块-废弃-请使用后台的代码生成"><a href="#创建模块-废弃-请使用后台的代码生成" class="header-anchor">#</a> 创建模块（废弃）请使用后台的代码生成</h2> <p>如果你想使用模块式开发，请使用下面命令生成模块</p> <div class="language- extra-class"><pre class="language-text"><code>php think create:module moduleName
</code></pre></div><h4 id="参数"><a href="#参数" class="header-anchor">#</a> 参数</h4> <ul><li><code>moduleName</code> 模块名称</li></ul> <p>该命令会在 <code>catch</code> 目录下生成模块文件夹，默认有三个文件加上若干文件夹</p> <ul><li><code>moduleService.php</code>  // 服务启动文件</li> <li><code>route.php</code> // 路由文件</li> <li><code>module.json</code>  // 模块信息描述文件</li></ul> <p>这样基本的模块就创建完毕了。</p> <h2 id="创建-migration"><a href="#创建-migration" class="header-anchor">#</a> 创建 Migration</h2> <div class="language- extra-class"><pre class="language-text"><code>php think catch-migrate:create
</code></pre></div><h4 id="参数-2"><a href="#参数-2" class="header-anchor">#</a> 参数</h4> <ul><li>必选参数 <code>module</code>, 模块名称</li> <li>必选参数 <code>MigrationName</code>，驼峰法命名</li></ul> <h4 id="实例"><a href="#实例" class="header-anchor">#</a> 实例</h4> <div class="language- extra-class"><pre class="language-text"><code>php think catch-migrate:create permissions RoleHasPermissions
</code></pre></div><h2 id="创建表"><a href="#创建表" class="header-anchor">#</a> 创建表</h2> <p>在创建完<code>migrations</code>，需要设计表结构。可以在官方文档上看到如何使用<a href="https://www.kancloud.cn/manual/thinkphp6_0/1118028" target="_blank" rel="noopener noreferrer">数据迁移<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>,当你设计完结构之后，如果还有默认数据的话，需要使用 seeds 进行填充。在做完这些工作之后，使用以下命令</p> <div class="language- extra-class"><pre class="language-text"><code>php think catch-migrate:run module
</code></pre></div><div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>该命令可以生成对应的表结构</p></div> <div class="language- extra-class"><pre class="language-text"><code>php think catch-seed:run module
</code></pre></div><div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>该命令可以填充对应的表数据</p></div> <h2 id="创建模型"><a href="#创建模型" class="header-anchor">#</a> 创建模型</h2> <p>当你创建表成功后，还需要生成对应的模型，如果你是自己创建模型的话，还要填充表字段将会很浪费时间，所以才会有该命令的产生。</p> <div class="language- extra-class"><pre class="language-text"><code>php think create:model moduleName modelName
</code></pre></div><h5 id="参数-3"><a href="#参数-3" class="header-anchor">#</a> 参数</h5> <ul><li><code>moduelName</code> 模块名称</li> <li><code>modelName</code> 模型名称</li> <li>可选参数 <code>--softDelete</code> 值:<code>SOFTDELETE</code> 软删除参数之后，使用的模型会有区别，请注意</li></ul> <p><code>模型名称</code>和<code>模块名</code>称都是必须的，模型名称还必须是驼峰规则，不然会找不到表，例如你的表名是<code>user_role</code>,那么你的模型名称就应该是 <code>UserRole</code> 这样的驼峰命名，这是约定。</p> <h2 id="模块禁用"><a href="#模块禁用" class="header-anchor">#</a> 模块禁用</h2> <p>如果不想使用某个模块了，可以使用下面的命令。</p> <div class="language- extra-class"><pre class="language-text"><code>php think disable:module moduleName
</code></pre></div><div class="custom-block warning"><p class="custom-block-title">WARNING</p> <p>该命令使用之后会将相关菜单全部删除。</p></div> <h2 id="模块启用"><a href="#模块启用" class="header-anchor">#</a> 模块启用</h2> <p>如果想继续使用某个模块了，可以使用下面的命令。</p> <div class="language- extra-class"><pre class="language-text"><code>php think enable:module moduleName
</code></pre></div><div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>该命令使用之后会将相关删除菜单全部恢复。</p></div> <h2 id="打包模块"><a href="#打包模块" class="header-anchor">#</a> 打包模块</h2> <div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>这是预留命令，目前来看没有任何作用</p></div> <div class="language- extra-class"><pre class="language-text"><code>php think package:zip module
</code></pre></div><p>该命令会将文件夹压缩成ZIP包。</p> <h2 id="模块服务发现"><a href="#模块服务发现" class="header-anchor">#</a> 模块服务发现</h2> <p>在 <code>catchAdmin</code> 中使用多模块的时候，必须使用服务发现，保证模块的可用</p> <div class="language- extra-class"><pre class="language-text"><code>php think catch-service:discover
</code></pre></div><h2 id="导出菜单"><a href="#导出菜单" class="header-anchor">#</a> 导出菜单</h2> <p>目前 CatchAdmin 由于模块独立，所以安装模块的时候对于权限菜单也是独立的，所以当你开发完独立的模块之后，应该是需要单独导出菜单的。所以提供了很简单的命令，支持树状导出。</p> <div class="language-sh extra-class"><pre class="language-sh"><code>php think <span class="token builtin class-name">export</span> permissions -p parent_id -m system
</code></pre></div><ul><li>permissions 就是权限表,根据实际填写
<ul><li><code>-p</code> 树状的父级标识，CatchAdmin permissions 表使用 <code>parent</code></li> <li><code>-m</code> 导出的模块名称</li></ul></li></ul> <h2 id="执行-migrate"><a href="#执行-migrate" class="header-anchor">#</a> 执行 migrate</h2> <p>项目有时候需要更新，新增字段，借助 migration，可以很好的管理表字段的版本。</p> <div class="language-sh extra-class"><pre class="language-sh"><code>php think catch-migrate:run moduleName
</code></pre></div><p>可以很好更新模块下的 <code>migration</code></p> <h2 id="填充数据"><a href="#填充数据" class="header-anchor">#</a> 填充数据</h2> <p>如果模块有初始化数据需要填充，那么就需要下面的命令</p> <div class="language-sh extra-class"><pre class="language-sh"><code>php think catch-seed:run moduleName
</code></pre></div><p>这个命令是更新模块下所有 <code>seed</code>，因为 <code>seed</code> 是没有版本控制的，所以你不能每次都去执行模块下所有的 <code>seeder</code>，你可以指定执行某个 seeder.</p> <div class="language-sh extra-class"><pre class="language-sh"><code>php think catch-seed:run moduleName -s SeederClass
</code></pre></div><h2 id="缓存敏感词"><a href="#缓存敏感词" class="header-anchor">#</a> 缓存敏感词</h2> <div class="language-sh extra-class"><pre class="language-sh"><code>php think cache:sensitiveWord
</code></pre></div><h2 id="重置超管密码"><a href="#重置超管密码" class="header-anchor">#</a> 重置超管密码</h2> <div class="language-sh extra-class"><pre class="language-sh"><code>php think cache:initAdmin
</code></pre></div><p>默认密码是 <code>catchadmin</code></p></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/catch-admin/document/edit/master/docs/docs/console.md" target="_blank" rel="noopener noreferrer">在 Github 编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">更新时间:</span> <span class="time">11/23/2020, 6:16:27 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"><a href="/docs/project-introduce.html" class="prev"><i aria-label="icon: left" class="anticon anticon-left"><svg viewBox="64 64 896 896" focusable="false" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 0 0 0 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"></path></svg></i>
        目录结构
      </a></span> <span class="next"><a href="/docs/request.html">
        请求介绍
        <i aria-label="icon: right" class="anticon anticon-right"><svg viewBox="64 64 896 896" focusable="false" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4z"></path></svg></i></a></span></p></div> </main> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.d0396f44.js" defer></script><script src="/assets/js/2.1cef47df.js" defer></script><script src="/assets/js/8.35122549.js" defer></script>
  </body>
</html>